﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;
using System.Collections;

namespace PJ.Data.SalePurchase.Sale
{
    public sealed class SaleInvoiceAXProvider : EntityAXProvider<ISaleInvoiceData>, ISaleInvoiceProvider
    {
        public SaleInvoiceAXProvider(ISaleInvoiceCache<ISaleInvoiceData> cache)
            : base(cache)
        {
        }


        public override ISaleInvoiceData CreateNewItem()
        {
            return new BaseSaleInvoiceData();
        }


        protected override void CopyFromContainer(IEnumerator enumerator, ISaleInvoiceData data)
        {
            base.CopyFromContainer(enumerator, data);
            if (enumerator.MoveNext())
            {
                EntityFragmentAXProvider.CopyFromContainer(enumerator, data);  
            }
            else
                throw new ArgumentException("Container size error", "enumerator");
        }

        public string[] GetFragments(string ownerId, GetDataMode mode)
        {
            return EntityFragmentAXProvider.GetFragments(this.GetType(), (IEntityFragmentCache)Cache, ownerId, mode);   
        }

    }
}
